[#ftl]
[#list configs as dt]
[#assign data = dt]
[#assign usedIPs = dt.usedIPs]
[#assign peripheralParams = dt.peripheralParams]
[#assign peripheralGPIOParams = dt.peripheralGPIOParams]
[#assign peripheralDMAParams = dt.peripheralDMAParams]
[#assign peripheralNVICParams = dt.peripheralNVICParams]
[#assign deviceFamily="${dt.family}xx"]
[#assign stm32f030x6_devices = ["STM32F030C6", "STM32F030F4", "STM32F030K6"]]
[#assign stm32f030x8_devices = ["STM32F030C8", "STM32F030R8"]]
[#assign stm32f030xc_devices = ["STM32F030CC", "STM32F030RC"]]
[#assign stm32f070x6_devices = ["STM32F070C6", "STM32F070F6"]]
[#assign stm32f070xb_devices = ["STM32F070CB", "STM32F070RB"]]
[#assign tmpName= "STM32F0"+"${dt.device[7]}"+"${dt.device[8]}"+"${dt.device[9]}"+"${dt.device[10]}"]
[#if     tmpName?starts_with("STM32F030")]
  [#if     stm32f030x6_devices?seq_contains(tmpName)]
    [#assign startupFile = "startup_stm32f030x6.s"]
  [#elseif stm32f030x8_devices?seq_contains(tmpName)]
    [#assign startupFile = "startup_stm32f030x8.s"]
  [#elseif stm32f030xc_devices?seq_contains(tmpName)]
    [#assign startupFile = "startup_stm32f030xc.s"]
  [/#if]
[#elseif  tmpName?starts_with("STM32F031")]
  [#assign startupFile = "startup_stm32f031x6.s"]
[#elseif  tmpName?starts_with("STM32F038")]
  [#assign startupFile = "startup_stm32f038xx.s"]
[#elseif  tmpName?starts_with("STM32F042")]
  [#assign startupFile = "startup_stm32f042x6.s"]
[#elseif  tmpName?starts_with("STM32F048")]
  [#assign startupFile = "startup_stm32f048xx.s"]
[#elseif  tmpName?starts_with("STM32F051")]
  [#assign startupFile = "startup_stm32f051x8.s"]
[#elseif  tmpName?starts_with("STM32F058")]
  [#assign startupFile = "startup_stm32f058xx.s"]
[#elseif  tmpName?starts_with("STM32F070")]
  [#if     stm32f070x6_devices?seq_contains(tmpName)]
    [#assign startupFile = "startup_stm32f070x6.s"]
  [#elseif stm32f070xb_devices?seq_contains(tmpName)]
    [#assign startupFile = "startup_stm32f070xb.s"]
  [/#if]
[#elseif  tmpName?starts_with("STM32F071")]
  [#assign startupFile = "startup_stm32f071xb.s"]
[#elseif  tmpName?starts_with("STM32F072")]
  [#assign startupFile = "startup_stm32f072xb.s"]
[#elseif  tmpName?starts_with("STM32F078")]
  [#assign startupFile = "startup_stm32f078xx.s"]
[#elseif  tmpName?starts_with("STM32F091")]
  [#assign startupFile = "startup_stm32f091xc.s"]
[#elseif  tmpName?starts_with("STM32F098")]
  [#assign startupFile = "startup_stm32f098xx.s"]
[/#if]  
[#assign ll_used = 0]
[#assign hal_used = 0]
[#list usedIPs as ip]
[#if peripheralParams.get(ip)?? && peripheralParams.get(ip).get("driver") == ("LL")]
  [#assign ll_used = 1]
[/#if]
[#if ip?starts_with("NVIC") == false]
[#if peripheralParams.get(ip)?? && peripheralParams.get(ip).get("driver") == ("HAL")]
  [#assign hal_used = 1]
[/#if]
[/#if]
[/#list]
[#assign timebase_tim = 0]
[#if timeBaseSource?? && timeBaseSource!="SysTick"]
[#assign timebase_tim = 1]
[/#if]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- ******************************************************************************
 * File Name   : FrameworkCubeMX.gpdsc
 * Date        : ${date}
 * Description : Generator PDSC File generated by STM32CubeMX (DO NOT EDIT!)
 ****************************************************************************** -->
<package xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.0" xs:noNamespaceSchemaLocation="PACK.xsd">
  <vendor>Keil</vendor>
  <name>FrameworkCubeMX</name>
  <description>STM32CubeMX generated pack description</description>
  <url>project-path</url>
  <releases>
    <release version="1.0.0">
     - Generated: ${date}
    </release>
  </releases>
  <generators>
    <generator id="STM32CubeMX" Gvendor="STMicroelectronics" Gtool="STM32CubeMX" Gversion="4.10.0">
      <description>STM32CubeMX Environment</description>
      <select Dname="${(dt.device)}" Dvendor="STMicroelectronics:13"/>
      <command>$SMDK\CubeMX\STM32CubeMXLauncher</command>
      <workingDir>$PRTE\Device\${(dt.device)}</workingDir>
      <project_files>
        <file category="include" name="STCubeGenerated/Inc/"/>
        <file category="source" name="STCubeGenerated/Src/main.c" />
        <file category="header" name="STCubeGenerated/Inc/${deviceFamily?lower_case}_it.h"/>
        <file category="source" name="STCubeGenerated/Src/${deviceFamily?lower_case}_it.c"/>
      </project_files>
    </generator>
  </generators>
  <taxonomy>
    <description Cclass="Device" Cgroup="STM32Cube Framework" generator="STM32CubeMX">STM32Cube Framework</description>
  </taxonomy>
  <conditions>
    <condition id="STCubeMX">
      <description>Condition to include CMSIS core, Device Startup and HAL Drivers components</description>
      <require Dvendor="STMicroelectronics:13" Dname="STM32F0*"/>
      <require Cclass="CMSIS"  Cgroup="CORE"/>
      <require Cclass="Device" Cgroup="Startup"/>
      <require Cclass="Device" Cgroup="STM32Cube HAL"/>
    </condition>
  </conditions>
  <components>
    <bundle Cbundle="STM32CubeMX" Cclass="Device" Cversion="1.0.0">
      <component generator="STM32CubeMX" Cvendor="Keil" Cgroup="STM32Cube Framework" Csub="STM32CubeMX" Cversion="1.1.0" condition="STCubeMX">
        <description>Configuration via STM32CubeMX</description>
        <RTE_Components_h>
[#if ll_used == 1]
          #define RTE_DEVICE_LL_DRIVERS_USED
[/#if]
          #define RTE_DEVICE_FRAMEWORK_CUBE_MX
        </RTE_Components_h>
        <files>
          <file category="header" name="MX_Device.h"/>
          <file category="header" name="STCubeGenerated/Inc/${deviceFamily?lower_case}_hal_conf.h"/>
[#if hal_used == 1]
          <file category="source" name="STCubeGenerated/Src/${deviceFamily?lower_case}_hal_msp.c"/>
[/#if]
[#if timebase_tim == 1]
          <file category="source" name="STCubeGenerated/Src/${deviceFamily?lower_case}_hal_timebase_tim.c"/>
[/#if]
        </files>
      </component>
      <component  Cgroup="Startup">
        <description>System Startup for STMicroelectronics</description>
        <files>
          <file category="source" name="STCubeGenerated/MDK-ARM/${startupFile}" />
          <file category="source" name="STCubeGenerated/Src/system_${deviceFamily?lower_case}.c" />
        </files>
      </component>
    </bundle>
  </components>
</package>
[/#list]
